<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="inet.db.tennis.TennisChampion"%>
<%@page import="inet.db.tennis.buffer.TennisSeasonBuffer"%>
<%@page import="inet.db.tennis.TennisSeason"%>
<%@page import="inet.db.tennis.buffer.TennisBuffer"%>
<jsp:useBean id="tennisChampionDAO" class="inet.db.tennis.TennisChampionDAO" scope="session"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Danh sách giải đấu</title>
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/reset.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/text.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/grid.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/admin/tennis/css/nav.css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="css/ie.css" media="screen" /><![endif]-->
    <link href="<%= request.getContextPath() %>/admin/tennis/css/table/demo_page.css" rel="stylesheet" type="text/css" />
    <!-- BEGIN: load jquery -->
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script type="<%= request.getContextPath() %>/admin/tennis/text/javascript" src="js/jquery-ui/jquery.ui.core.min.js"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.widget.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.accordion.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.effects.core.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.effects.slide.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.mouse.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/jquery-ui/jquery.ui.sortable.min.js" type="text/javascript"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/table/jquery.dataTables.min.js" type="text/javascript"></script>
    <!-- END: load jquery -->
    <script type="text/javascript" src="<%= request.getContextPath() %>/admin/tennis/js/table/table.js"></script>
    <script src="<%= request.getContextPath() %>/admin/tennis/js/setup.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            setupLeftMenu();

            var oTable = $('.datatable').dataTable();
            oTable.fnSort( [ [1,'asc'] ] );
			setSidebarHeight();
        });
    </script>
</head>
<body>
    <div class="container_12">
        <%@ include file="../include/header.jsp" %>
        <% 
        	Vector<TennisChampion> vTennisChampion = tennisChampionDAO.findAll();
        %>
        <div class="grid_10">
            <div class="box round first grid">
                <h2>Danh sách giải đấu</h2>
                <div class="block">
                	<form name="formListChampion" method="post">
	                    <table class="data display datatable" id="example">
							<thead>
								<tr>
									<th style="width: 5%;">&nbsp;</th>
									<th style="width: 8%;">Code</th>
									<th style="width: 15%;">Tên giải</th>
									<th style="width: 10%;">Mùa giải hiện tại</th>
									<th style="width: 10%;">Vòng hiện tại</th>
									<th style="width: 10%;">Tay vợt</th>
									<th style="width: 10%;">Thứ hạng</th>
									<th style="width: 10%;">Quốc gia</th>
									<th style="width: 5%;">Map</th>
									<th style="width: 5%;">Sửa</th>
									<th style="width: 5%;">Tạo cặp</th>
								</tr>
							</thead>
							<tbody>
								<% 
									if(vTennisChampion != null && !vTennisChampion.isEmpty()) {
										TennisChampion champion = null;
										int i = 0;
										String seasonName = "";
										Map seasonTable = TennisSeasonBuffer.getSeasonTable();
										TennisSeason season = null;
										for (Iterator it = vTennisChampion.iterator(); it.hasNext(); ) {
											champion = (TennisChampion)it.next();
											if( champion == null ) continue;
											if( champion.getCurrentSeason() != null) {
												season = (TennisSeason) seasonTable.get(champion.getCurrentSeason());
												if (season != null){
													seasonName = season.getSeasonName();
												} else {
													seasonName = "";
												}
											} else {
												seasonName = "";
											}
								%>
								<tr class="gradeA">
									<td><input type="checkbox" name="chkID" value="<%= champion.getId() %>" /></td>
									<td><%= champion.getCodeSMS() %></td>
									<td><%= champion.getName() %></td>
									<td>
										<a href="list-season.jsp?championCode=<%= champion.getCode() %>">
											<%= !"".equals(seasonName) ? seasonName:" Chưa có "  %>
										</a>
									</td>
									<td><%= champion.getCurrentRound() != null ? champion.getCurrentRound():"" %></td>
									<td>
										<a href="list-player-champion.jsp?championCode=<%= champion.getCode() %>">
											[View]
										</a>
									</td>
									<td>Hạng 1</td>
									<td><%= champion.getCountryName() %></td>
									<td>US Open</td>
									<td align="center">
										<a href="edit.jsp?id=<%= champion.getId() %>">
											<img alt="Sửa" style="vertical-align: middle;" src="<%= request.getContextPath() %>/admin/tennis/img/cog.png" />
										</a>
									</td>
									<td align="center">
										<a href="<%= request.getContextPath() %>/admin/tennis/match/create-schedule.jsp?championCode=<%= champion.getCode() %>">
											<img title="Tạo cặp đấu giải <%= champion.getName() %>" alt="Tạo cặp" style="vertical-align: middle;" src="<%= request.getContextPath() %>/admin/tennis/img/create.png" /> 
										</a>
									</td>
								</tr>
								<% 
										}
									}
								%>
							</tbody>
						</table>
					</form>
					<a href="add.jsp" class="btn-mini btn-black btn-plus" title="Thêm mới"><span></span>Add</a>
                </div>
            </div>
        </div>
        <div class="clear">
        </div>
    </div>
    <%@ include file="../include/footer.jsp" %>
</body>
</html>